/*
 * author: 徐冉辰 2021080908028
 */

#pragma once

#include <iostream>
#include <fstream>
#include <filesystem>
#include <iomanip>
#include <string>
#include <exception>

#include "StatePattern.hpp"

/*
 * 词法分析器
 */
class LexAnalysis
{
private:
    std::ifstream ifs_source;
    std::ofstream ofs_result, ofs_error;

    std::string lineString;
    std::string::const_iterator currentChar;

    Token token;
    Tokenizer tokenizer;

    void loadData(std::filesystem::path sourceFile);
    void outputToken();
    void formateErrorOutput(std::string error_info);

public:
    int token_number;
    int line_number;
    int error_number;

    LexAnalysis() : token_number(0), line_number(0), error_number(0) {}
    ~LexAnalysis();

    void lineScanner(std::filesystem::path sourceFile);
};
